use bcrypt::DEFAULT_COST;

pub fn hash(password: &str) -> String {
    bcrypt::hash(password, DEFAULT_COST).expect("加密失败")
}

pub fn verify(password: &str, hashed_password: &str) -> bool {
    let res = bcrypt::verify(password, hashed_password);
    match res {
        Ok(boolean) => boolean,
        Err(err) => {
            println!("密码校验错误：{err}");
            false
        }
    }
}
